// 2025/09/16
// Author: Forever
#include <bits/stdc++.h>
using namespace std;

int n, m, in[100005];
vector<int> input[50005], edge[100001];

vector<int> solve(int x)
{
    memset(in, 0, sizeof(in));
    for (int i = 1; i <= n; i++)
        edge[i].clear();
    for (int i = 1; i <= x; i++)
        for (int j = 0; j < input[i].size() - 1; j++)
            edge[input[i][j]].push_back(input[i][j + 1]), in[input[i][j + 1]]++;
    priority_queue<int, vector<int>, greater<int>> q;
    for (int i = 1; i <= n; i++)
        if (!in[i])
            q.push(i);
    vector<int> ans;
    while (q.size()) {
        int u = q.top();
        q.pop();
        ans.push_back(u);
        for (int v : edge[u])
            if (--in[v] == 0)
                q.push(v);
    }
    return ans;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x;
        for (int j = 1; j <= x; j++)
            cin >> y, input[i].push_back(y);
    }
    int l = 0, r = m;
    while (l <= r) {
        int mid = (l + r) >> 1;
        vector<int> ans = solve(mid);
        if (ans.size() == n)
            l = mid + 1;
        else
            r = mid - 1;
    }
    vector<int> ans = solve(r);
    for (int i = 0; i < ans.size(); i++)
        cout << ans[i] << ' ';
    cout << endl;
    return 0;
}